// Define the namespace
jmaki.namespace("jmaki.widgets.yahoo.autocomplete");

/**
 * Yahoo UI Autocomplete Widget
 *
 * @author Edwin Goei
 * @see http://developer.yahoo.com/yui/autocomplete/
 */
jmaki.widgets.yahoo.autocomplete.Widget = function(wargs) {
    
    var topic = "/yahoo/autocomplete";
    var uuid = wargs.uuid; 
    var self = this;
    var service = wargs.service
    var containerId = uuid + "_container";
    var autoComp;
    var completionMethod;

    //overide topic name if needed
    if (wargs.args && wargs.args.topic) {
        topic = wargs.args.topic;
    }

    if (wargs.args && wargs.args.completionMethod) {
        completionMethod = wargs.args.completionMethod;
    }

    this.init = function() {
	var schema = ["item", "title"];
	var ds = new YAHOO.widget.DS_XHR(service, schema);
	ds.responseType = YAHOO.widget.DS_XHR.TYPE_XML;
	ds.scriptQueryAppend = "method=" + completionMethod;
	autoComp = new YAHOO.widget.AutoComplete(uuid, containerId, ds);
    }
    
    this.init();
}
